//
//  allOrderCell.m
//  Recycling
//
//  Created by jzd on 2018/6/2.
//  Copyright © 2018年 宋佳. All rights reserved.
//

#import "allOrderCell.h"
@interface allOrderCell ()
@property (weak, nonatomic) IBOutlet UIButton *telBtn;
@property (weak, nonatomic) IBOutlet UILabel *userName;
@property (weak, nonatomic) IBOutlet UIButton *addressB;
@property (weak, nonatomic) IBOutlet UILabel *type;
@property (weak, nonatomic) IBOutlet UILabel *time;
@property (weak, nonatomic) IBOutlet UILabel *price;

@end
@implementation allOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.layer.cornerRadius = 5;
    self.contentView.layer.masksToBounds = YES;
}
-(void)setModel:(orderModel *)model{
    _model = model;
    self.userName.text = model.UserName;
    [self.telBtn setTitle:model.UserTel forState:UIControlStateNormal];
    NSString *str = self.telBtn.titleLabel.text;
    NSMutableAttributedString *tncString = [[NSMutableAttributedString alloc]initWithString:str];
    [tncString addAttribute:NSUnderlineStyleAttributeName
                      value:@(NSUnderlineStyleSingle)
                      range:(NSRange){0,[tncString length]}];
    //此时如果设置字体颜色要这样
    [tncString addAttribute:NSForegroundColorAttributeName value:TITLECOLOR  range:NSMakeRange(0,[tncString length])];
    
    //设置下划线颜色...
    [tncString addAttribute:NSUnderlineColorAttributeName value:TITLECOLOR range:(NSRange){0,[tncString length]}];
    [self.telBtn setAttributedTitle:tncString forState:UIControlStateNormal];
    
    [self.addressB setTitle:model.UserAddress forState:UIControlStateNormal];
    self.type.text = [NSString stringWithFormat:@"%@%@%@",model.ProBrandName,model.ProSpecName,model.ProTypeName];
    self.time.text = model.AppointmentDate;
    self.price.text = [NSString stringWithFormat:@"%.2f",model.MessagePrice];
}
-(void)setFrame:(CGRect)frame{
    frame = CGRectMake(frame.origin.x+5, frame.origin.y+5, frame.size.width-10, frame.size.height-10);
    [super setFrame:frame];
}
- (IBAction)telOnClick:(UIButton *)sender {
    NSString *resourceSpecifier = self.telBtn.currentAttributedTitle.string;
    NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@",resourceSpecifier];
    if (@available(iOS 10.0, *)) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
    } else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
    }
}
@end
